import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue()
  ],
  define: {
    'process.env': {
      BASE_API:"http://47.102.207.56:8888/Tomori/"
    },
  },
  base: './',
  resolve: {
    alias: {
      '@': path.resolve("src"),
      'static': path.resolve("src/assets"),
      "@api": path.resolve("src/api"),
      "@comps": path.resolve("src/components"),
      "~style":path.resolve("src/assets/css")
    }
  },
  build: {
    rollupOptions: {
      output: {
        chunkFileNames: 'static/js/[name]-[hash].js',
        entryFileNames: 'static/js/[name]-[hash].js',
        assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
      }
    }
  },
  // 配置scss全局变量
  css: {
    preprocessorOptions: {
      // 全局样式引入
      scss: {
        additionalData: `@import '@/theme/main_color.scss';`,
        javascriptEnabled: true
      }
    }
  },
  server: {
    proxy: {
      'api': {
        target: 'http://47.102.207.56:8888/Tomori/',
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, ''),
      },
    }
  },
})
